package com.hubspot.singularity;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Optional;

@Schema(description = "Describes an in-progress deploy")
public class SingularityPendingDeploy {
  private final SingularityDeployMarker deployMarker;
  private final DeployState currentDeployState;
  private final SingularityDeployProgress deployProgress;
  private final Optional<SingularityRequest> updatedRequest;

  @JsonCreator
  public SingularityPendingDeploy(
    @JsonProperty("deployMarker") SingularityDeployMarker deployMarker,
    @JsonProperty("currentDeployState") DeployState currentDeployState,
    @JsonProperty("deployProgress") SingularityDeployProgress deployProgress,
    @JsonProperty("updatedRequest") Optional<SingularityRequest> updatedRequest
  ) {
    this.deployMarker = deployMarker;
    this.currentDeployState = currentDeployState;
    this.deployProgress = deployProgress;
    this.updatedRequest = updatedRequest;
  }

  @Schema(description = "Uniquely identifies this deploy")
  public SingularityDeployMarker getDeployMarker() {
    return deployMarker;
  }

  @Schema(description = "Current state of this deploy")
  public DeployState getCurrentDeployState() {
    return currentDeployState;
  }

  @Schema(
    description = "Describes the progress this deploy has made so far",
    nullable = true
  )
  public SingularityDeployProgress getDeployProgress() {
    return deployProgress;
  }

  @Schema(description = "New request data to be committed if this deploy succeeds")
  public Optional<SingularityRequest> getUpdatedRequest() {
    return updatedRequest;
  }

  @Override
  public String toString() {
    return (
      "SingularityPendingDeploy{" +
      "deployMarker=" +
      deployMarker +
      ", currentDeployState=" +
      currentDeployState +
      ", deployProgress=" +
      deployProgress +
      ", updatedRequest=" +
      updatedRequest +
      '}'
    );
  }
}
